package com.qf.test.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.test.mapper.DtsOrderGoodsMapper;
import com.qf.test.mapper.DtsOrderMapper;
import com.qf.test.mapper.DtsUserMapper;
import com.qf.test.pojo.DtsOrder;
import com.qf.test.pojo.DtsOrderGoods;
import com.qf.test.pojo.DtsUser;
import com.qf.test.vo.OrederVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OrderGoodsServiceImpl implements OrderGoodsService {
    @Autowired
    private DtsOrderGoodsMapper dtsOrderGoodsMapper;
    @Autowired
    private DtsUserMapper userMapper;
    @Autowired
    private DtsOrderMapper dtsOrderMapper;


    /**
     * 查找所有的订单详情
     *
     * @return
     */
    @Override
    public List<DtsOrderGoods> findByOrderId(String id ) {
        QueryWrapper<DtsOrderGoods> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deleted", false);
        queryWrapper.eq("id", id);
        List<DtsOrderGoods> list = dtsOrderGoodsMapper.selectList(queryWrapper);
        return list;
    }

    /**
     * 订单对应的发货公司
     * @return
     */
    @Override
    public List<OrederVo> findall() {
        List<OrederVo> list = dtsOrderGoodsMapper.findAll();
        return list;
    }

    /**
     * 根据用户名的名字
     */
    public List<DtsUser> findnameById(String id){
        List<DtsUser> list = userMapper.findusername();
        return list;
    }
    /**
     * 查询所有的订单
     */
    public List<DtsOrder> findByUserId(){
        QueryWrapper<DtsOrder> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted",false);
        List<DtsOrder> list = dtsOrderMapper.selectList(wrapper);
        return list;
    }
}
